package com.photoeditor.demo.ui.dialog;

import android.content.Context;

import com.photoeditor.demo.model.preference.SPDataManager;
import com.photoeditor.demo.model.preference.SpUtils;
import com.photoeditor.demo.model.subscribe.strategy.OneFreeStrategyManager;
import com.photoeditor.demo.model.subscribe.strategy.RateNewStrategyBean;
import com.photoeditor.demo.statistics.StatisticsConstant;
import com.photoeditor.demo.statistics.StatisticsUtils;

import static com.photoeditor.demo.model.preference.SpUtils.EFFECT_NAME;
import static com.photoeditor.demo.model.subscribe.strategy.OneFreeStrategyManager.ADVANCE_OBTAIN_RESULT;
import static com.photoeditor.demo.model.subscribe.strategy.OneFreeStrategyManager.ORIGINAL_RATE_GUIDE;

public class WDialogShow {


    /**
     * 幸运用户/激励视频弹窗
     *
     * @param context
     * @param entrance 入口
     * @param retain
     * @param where    统计用入口
     * @param listener
     */
    public static void showLuckyUserOrInspireAdVideoDialog(Context context, DialogShow.InspireDialogEntrance entrance,
                                                           String retain, @DialogStatistic.AdVideoWhere final int where, IDialog.IListener listener) {
        //策略平台控制，0——旧样式，1——AD弹框，2——评分引导一天免费弹框
        RateNewStrategyBean.RateNewStrategyBeanConfig beanConfig = OneFreeStrategyManager.getOneFreeVipOrAdStrategyConfig();
        if (beanConfig == null) {
            return;
        }
        switch (beanConfig.getRateType()) {
            case ORIGINAL_RATE_GUIDE:
                break;
            case ADVANCE_OBTAIN_RESULT:
                DialogShow.showAdVideoDialog(entrance, context, retain, where, new IDialog.Listener() {
                    @Override
                    public void yes() {
                        //弹窗展示后,计入统计
                        SPDataManager.setIsShowAdvanceDialog(false);
                        if (where != DialogStatistic.AdVideoWhere.VALUE_WHERE_TOOL) {
                            SPDataManager.hasShowedAdVideoDialogInAdvanceResultPage();
                        }
                        if(where==DialogStatistic.AdVideoWhere.VALUE_WHERE_FACE_AGING){
                            StatisticsUtils.statisticGrowingIo(StatisticsConstant.EVENT_VIDEO_BUTTON_SHOW,
                                    StatisticsConstant.KEY_SHOW_TYPE, StatisticsConstant.VALUE_POPUP,
                                    StatisticsConstant.KEY_VIP_FUN, StatisticsConstant.VALUE_VIP_FUN_FACE_AGING,
                                    StatisticsConstant.KEY_FILTER_NAME, StatisticsConstant.VALUE_VIP_FUN_FACE_AGING);
                        }else if(where==DialogStatistic.AdVideoWhere.VALUE_WHERE_GENDER_SWAP) {
                            StatisticsUtils.statisticGrowingIo(StatisticsConstant.EVENT_VIDEO_BUTTON_SHOW,
                                    StatisticsConstant.KEY_SHOW_TYPE, StatisticsConstant.VALUE_POPUP,
                                    StatisticsConstant.KEY_VIP_FUN, StatisticsConstant.VALUE_VIP_FUN_FACE_SWAP,
                                    StatisticsConstant.KEY_FILTER_NAME, StatisticsConstant.VALUE_VIP_FUN_FACE_SWAP);
                        }else if(where==DialogStatistic.AdVideoWhere.VALUE_WHERE_PAST_LIFE){
                            StatisticsUtils.statisticGrowingIo(StatisticsConstant.EVENT_VIDEO_BUTTON_SHOW,
                                    StatisticsConstant.KEY_SHOW_TYPE, StatisticsConstant.VALUE_POPUP,
                                    StatisticsConstant.KEY_VIP_FUN, StatisticsConstant.VALUE_VIP_FUN_PAST_LIFE,
                                    StatisticsConstant.KEY_FILTER_NAME,StatisticsConstant.VALUE_VIP_FUN_PAST_LIFE);
                        }else if(where==DialogStatistic.AdVideoWhere.VALUE_WHERE_MATERIAL){
                            StatisticsUtils.statisticGrowingIo(StatisticsConstant.EVENT_VIDEO_BUTTON_SHOW,
                                    StatisticsConstant.KEY_SHOW_TYPE, StatisticsConstant.VALUE_POPUP,
                                    StatisticsConstant.KEY_VIP_FUN, StatisticsConstant.VALUE_VIP_FUN_MATERIAL,
                                    StatisticsConstant.KEY_FILTER_NAME, SpUtils.obtain().getString(EFFECT_NAME, ""));
                        }else if(where==DialogStatistic.AdVideoWhere.VALUE_WHERE_TOOL){
                            StatisticsUtils.statisticGrowingIo(StatisticsConstant.EVENT_VIDEO_BUTTON_SHOW,
                                    StatisticsConstant.KEY_SHOW_TYPE, StatisticsConstant.VALUE_POPUP,
                                    StatisticsConstant.KEY_VIP_FUN, StatisticsConstant.VALUE_VIP_FUN_TOOL,
                                    StatisticsConstant.KEY_FILTER_NAME,StatisticsConstant.VALUE_VIP_FUN_TOOL);
                        }
                    }
                }, listener);
                break;
//            case RATE_OBTAIN_ONE_DAY_VIP:
//                DialogShow.showLuckyUserDialog(entrance, context, where, new IDialog.Listener() {
//                    @Override
//                    public void yes() {
//                        //弹窗展示后,计入统计
//                        SPDataManager.setIsShowObtainVipDialog(false);
//                    }
//                });
//                break;
            default:
                break;
        }
    }
}
